package converters;
  
import javax.faces.component.UIComponent;  
import javax.faces.context.FacesContext;  
import javax.faces.convert.Converter;  
import javax.faces.convert.FacesConverter;

import domain.DadServiceParametersDAO;
  
@FacesConverter(value="parameterConverter")
public class ParameterConverter implements Converter {  
  
    public Object getAsObject(FacesContext facesContext, UIComponent component, String submittedValue) {  
    	DadServiceParametersDAO s = null;
		if (submittedValue.trim().equals("")) {  
		    return null;  
		} else { 
			s = new DadServiceParametersDAO(Long.parseLong(submittedValue));
		}
        return s;
    }  
  
    public String getAsString(FacesContext facesContext, UIComponent component, Object value) {  
        if (value == null) {  
            return "";  
        } else if (value instanceof DadServiceParametersDAO){  
            return String.valueOf(((DadServiceParametersDAO) value).getName());  
        } else {
        	return value.toString();
        }  
    }  
}  